package cn.iocoder.yudao.module.enterprise.dal.mysql.model;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.enterprise.controller.admin.model.vo.ModelEmissionPageReqVO;
import cn.iocoder.yudao.module.enterprise.dal.dataobject.model.ModelEmissionDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 核算模型和排放源关联 Mapper
 *
 * @author StevenShen
 */
@Mapper
public interface ModelEmissionMapper extends BaseMapperX<ModelEmissionDO> {

    default PageResult<ModelEmissionDO> selectPage(ModelEmissionPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ModelEmissionDO>()
                .leIfPresent(ModelEmissionDO::getModelId, reqVO.getModelId())
                .orderByDesc(ModelEmissionDO::getId));
    }

    default List<ModelEmissionDO> selectListByModelId(Long modelId) {
        return selectList(ModelEmissionDO::getModelId, modelId);
    }

}
